function h=correlated_channel(nr,nt, correl_lower_bounds, correl_upper_bounds)

%correl_lower_bounds=0;
%correl_upper_bounds=.2;
		
r_bs=zeros(nt);
			
p=1;
while(p>0)
	rho=random('unif',correl_lower_bounds,correl_upper_bounds,nt,nt);
	theta=random('unif',0,2*pi,nt,nt);
	r_bs=rho.*cos(theta) + i*rho.*sin(theta);
	r_bs=tril(r_bs)+ctranspose(tril(r_bs));
	for x=1:nt
		r_bs(x,x)=1;
	end

	[cholesky,p]=chol(r_bs);
end
r_ms=zeros(nr);

p=1;
while(p>0)
	rho=random('unif',correl_lower_bounds,correl_upper_bounds,nr,nr);
	theta=random('unif',0,2*pi,nr,nr);
	r_ms=rho.*cos(theta) + i*rho.*sin(theta);
	r_ms=tril(r_ms)+ctranspose(tril(r_ms));
	for x=1:nr
		r_ms(x,x)=1;
	end
	[cholesky,p]=chol(r_ms);
end
r_mimo=kron(r_ms,r_bs);

			
a=random('normal',0,1,nr*nt,1) + i*random('norm',0,1,nr*nt,1);
[C,p]=chol(r_mimo);

A=C*a;
h=zeros(nr,nt);
for v=1:nr*nt
	h(floor((v-1)/nr)+1,mod(v-1,nr)+1)=A(v);	
end
	
h=h';
h=h(1:nr,1:nt);

	